﻿namespace IceCS.DataStructure.Core.LinearList
{
    /// <summary>
    /// 链表结点
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class ListNode<T>
    {
        #region 属性

        /// <summary>
        /// 当前节点数据
        /// </summary>
        public T Data { get; set; }

        /// <summary>
        /// 下一个节点
        /// </summary>
        public ListNode<T> Next { get; set; }

        /// <summary>
        /// 上一个节点
        /// </summary>
        public ListNode<T> Previous { get; set; }

        #endregion

        #region 构造函数

        /// <summary>
        /// 默认构造函数
        /// </summary>
        public ListNode()
        {
            Data = default;
            Next = null;
            Previous = null;
        }

        /// <summary>
        /// 非默认构造函数
        /// </summary>
        /// <param name="data">数据</param>
        /// <param name="next">下一个节点</param>
        public ListNode(T data, ListNode<T> next) : this()
        {
            Data = data;
            Next = next;
        }

        /// <summary>
        /// 非默认构造函数
        /// </summary>
        /// <param name="next">下一个节点</param>
        public ListNode(ListNode<T> next) : this()
        {
            Next = next;
        }

        /// <summary>
        /// 非默认构造函数
        /// </summary>
        /// <param name="data">数据</param>
        public ListNode(T data) : this()
        {
            Data = data;
            Next = null;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="data"></param>
        /// <param name="next"></param>
        /// <param name="previous"></param>
        public ListNode(T data, ListNode<T> next, ListNode<T> previous)
        {
            Data = data;
            Next = next;
            Previous = previous;
        }
        #endregion
    }
}
